package com.cloudpivot.receivales.esign.service;

import com.alibaba.fastjson.JSONObject;
import com.cloudpivot.receivales.esign.domain.FileEntity;
import com.cloudpivot.receivales.esign.domain.MessageEntity;
import com.cloudpivot.receivales.esign.domain.SignersEntity;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileInputStream;

public interface ESignService {

    /**
     * 发起文件签字流程
     */
    MessageEntity startFlow(MultipartFile file, JSONObject bodyJSON) throws Exception;

    /**
     * 获取token
     */
    MessageEntity getToken();

    /**
     * 获取文件上传地址
     */
    String getFileUploadUrl(FileEntity fileEntity, String token);

    /**
     * 上传文件流
     */
    String fileUpload(FileEntity fileEntity, String fileUploadUrl, FileInputStream inputStream);

    /**
     * 查询文件是否上传/转换PDF成功
     */
    MessageEntity fileCheck(String token, String fileId);

    /**
     * 获取签字的具体页数及坐标
     */
    SignersEntity[] getKeywordPositions(String fileId, String token, SignersEntity[] signers);

    /**
     * 基于文件发起签署
     */
    String createByFile(FileEntity fileEntity, String token, SignersEntity[] signers, String signFlowTitle, String notifyUrl);

    /**
     * 下载签署完成后的文件
     */
    MessageEntity fileDownload(String signFlowId);

    /**
     * E签宝返回的附件推送至CRM
     */
    String pushReportToCRM(String signFlowId);

    /**
     * E签宝返回的附件推送至BPM
     */
    String pushReportToBPM(String signFlowId);

    /**
     * 获取签署链接
     */
    String getSignUrl(String mobile, String signFlowId, String token) throws Exception;

    /**
     * 通过博圣短信服务发送短信
     */
    String postMessageToMobile(String mobile, String content) throws Exception;
}
